<?php

use Illuminate\Http\Request;
header('Access-Control-Allow-Origin:*');//跨域
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// Route::middleware('auth:api')->get('/user', function (Request $request) {
//     return $request->user();
// });
Route::group(['namespace' => 'Api'], function () {
    //轮播图接口
    Route::get('/banner', 'BannerController@list');

    //商品分类接口
    Route::get('/category', 'CategoryController@list');
    //商品接口
    Route::get('/commodity/list', 'CommodityController@commodityList');
    //商品详情
    Route::get('/commodity/detail', 'CommodityController@detail');
    //某个商品系列返回
    Route::get('/commodity/series', 'CommodityController@series');
    // 热销商品列表返回
    Route::get('/commodity/hot', 'CommodityController@hot');
    // 热销商品详情返回
    Route::get('/commodity/hot/detail', 'CommodityController@hotDetail');
    //首页最新10条商品返回
    Route::get('/commodity/latest_data', 'CommodityController@latestData');
    // 商品搜索（按商品名称） DOTO:
    Route::get('/commodity/search', 'CommodityController@search');
    // 商品搜索（按商品销量  从高到低） :
    Route::get('/commodity/sales_volume_desc', 'CommodityController@salesVolumeDesc');
    // 商品搜索（按商品价格  从高到低） :
    Route::get('/commodity/price_desc', 'CommodityController@priceDesc');
    //商品系列返回
    Route::get('/CommoditySeries/list', 'CommoditySeriesController@list');

    //商品加入购物车
    Route::post('/carts/add', 'CartController@add');
    //删除购物车商品
    Route::post('/carts/delete', 'CartController@delete');
    //删除购物车所有商品
    Route::get('/carts/delete_all', 'CartController@deleteAll');
    //用户购物车返回
    Route::get('/carts/list', 'CartController@list');

    //用户咨询信息添加
    Route::get('/information_reservation/add', 'InformationReservationController@add');
    //用户咨询信息列表返回
    Route::get('/information_reservation/list', 'InformationReservationController@list');

    //用户收货地址添加
    Route::get('/receiving_addres/add', 'ReceivingAddresController@add');
    // 收货地址详情
    Route::get('/receiving_addres/detail', 'ReceivingAddresController@detail');
    //用户收货地址修改
    Route::post('/receiving_addres/edit', 'ReceivingAddresController@edit');
    //用户收货地址删除
    Route::post('/receiving_addres/delete', 'ReceivingAddresController@delete');
    //用户收货地址返回
    Route::get('/receiving_addres/list', 'ReceivingAddresController@list');



    //用户收货地址返回
    Route::get('/order/list', 'OrderController@list');

    //产品搜索 DOTO:
    //综合
    Route::get('/product_search/comprehensive', 'ProductSearchController@comprehensive');
    //综合
    //按销量降序
    Route::get('/product_search/sales_volume_desc', 'ProductSearchController@salesVolumeDesc');
    //按销量升序
    Route::get('/product_search/sales_volume_asc', 'ProductSearchController@salesVolumeAsc');

    //公司信息
    Route::get('/company_information', 'CompanyInformationController@data');

    //案例中心列表
    Route::get('/case_center/list', 'CaseCenterController@list');
    //案例详情
    Route::get('/case_center/details', 'CaseCenterController@details');

    // 小程序登录
    Route::post('weapp/authorizations', 'AuthorizationsController@weappStore')
               ->name('api.weapp.authorizations.store');
   //用户注册
   Route::any('user/register','UserController@register');
   Route::any('user/get_openid','UserController@getOpenid');
   //用户登录
   Route::any('user/get_user','UserController@getUser');
   //wx dl
   Route::any('wx/login','UserController@login');


   //用户收货地址添加
   Route::post('/order/add', 'OrderController@add');
   //下单接口 (单个商品)
   Route::any('/order/placeorder', 'OrderController@placeOrder');
   //下单接口 (多个商品)
   Route::any('/order/place_many_order', 'OrderController@placeManyOrder');
   //统一下单接口
   Route::post('order/store','OrderController@store');
   //我的订单返回
   Route::get('order/list','OrderController@list');
   //已付款订单
   Route::get('order/already_paid','OrderController@alreadyPaid');
   //未付款订单
   Route::get('order/unpaid','OrderController@unpaid');
   //已发货订单
   Route::get('order/already_shipped','OrderController@alreadyShipped');
   //未发货订单
   Route::get('order/unshippe_delivery','OrderController@unshippedDelivery');
   //订单地址 返回
   Route::get('order/dizhi','OrderController@dizhi');
   //下单回调地址
   Route::any('order/callback','OrderController@orderCallback');
   // Route::any('order/status','OrderController@orderStatus');
   Route::any('order/status','OrderController@test');
   Route::get('/ad',function(){
     // dd(app('wechat.official_account.default'));
     // dd(app('wechat.official_account.default')->config->toArray());
     // dd(app('wechat.official_account')->user->list());
     // dd(app('wechat.official_account')->menu->list());
     // dd(app('wechat.mini_program.default')->config->toArray());
     // app('wechat.mini_program.default')
     // ->config->toArray();
     // app('wechat.mini_program.default')
     // ->config->toArray();
     // dd(EasyWechat::officialAccount()->user->list());
      dd(session('wechat.oauth_user.default'));
  })->middleware("wechat.oauth");
 Route::get('/test','UserController@test')->middleware("auth:api");
 //通过api中间件守卫
 // Route::group(['middleware' => 'auth:api'],function(){
 //    // Route::get('/test','UserController@test');
 // });
});
